package com.rbmh.network.controller;

import com.rbmh.network.service.FtpService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author Administrator
 * @date 2021/11/19
 */
@RestController
@AllArgsConstructor
@RequestMapping("/ftp")
@Slf4j
public class FtpController {

    private final FtpService ftpService;

    @PostMapping("/pullFtpFiles")
    public Map<String,String> pullFtpFiles(@RequestBody String dzzzdzs) {

        // 异步处理
        ftpService.pullFtpFiles(dzzzdzs);

        // 直接返回成功
        Map<String,String> rtnMap = new HashMap();
        rtnMap.put("code","0000");
        rtnMap.put("msg","success");
        rtnMap.put("data","");
        return rtnMap;
    }

    @PostMapping("/getFtpFileBase64")
    public Map<String,String> getFtpFileBase64(@RequestBody String dzzzdz) {

        // 直接返回成功
        Map<String,String> rtnMap = new HashMap();
        rtnMap.put("code","0000");
        rtnMap.put("msg","success");
        rtnMap.put("data",ftpService.getFtpFileBase64(dzzzdz));
        return rtnMap;
    }
}
